package com.elitesland.model;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * 系统配置.
 *
 * @author Kaiser（wang shao）
 * @date 2021-02-01
 */
@ConfigurationProperties(prefix = "el.demo")
public class SysConfigProperties {

    private String serverAddress;

    /**
     * 缓存相关配置
     */
    private final Cache cache = new Cache();

    /**
     * 微信相关配置
     */
    private final Wechat wechat = new Wechat();

    /**
     * 上传相关配置
     */
    private final Upload upload = new Upload();

    /**
     * 导出相关配置
     */
    private final Export export = new Export();

    public String getServerAddress() {
        return serverAddress;
    }

    public void setServerAddress(String serverAddress) {
        this.serverAddress = serverAddress;
    }

    public Cache getCache() {
        return cache;
    }

    public Wechat getWechat() {
        return wechat;
    }

    public Upload getUpload() {
        return upload;
    }

    public Export getExport() {
        return export;
    }

    public static class Cache {

        private String keyPrefix;

        public String getKeyPrefix() {
            return keyPrefix;
        }

        public void setKeyPrefix(String keyPrefix) {
            this.keyPrefix = keyPrefix;
        }
    }

    public static class Wechat {
        private final Applet applet = new Applet();

        public Applet getApplet() {
            return applet;
        }
    }

    public static class Applet {
        /**
         * 小程序ID
         */
        private String appId;

        /**
         * 小程序私钥
         */
        private String appSecret;

        public String getAppId() {
            return appId;
        }

        public void setAppId(String appId) {
            this.appId = appId;
        }

        public String getAppSecret() {
            return appSecret;
        }

        public void setAppSecret(String appSecret) {
            this.appSecret = appSecret;
        }
    }

    public static class Upload {

        /**
         * 服务器路径
         */
        private String serverUrl;
        /**
         * 连接超时
         */
        private Integer serverConnectTimeout = 5000;
        /**
         * 读取超时
         */
        private Integer serverReadTimeout = 60000;
        /**
         * 黑名单
         */
        private List<String> blockSuffixList;
        /**
         * 文件大小限制
         */
        private Long sizeLimit;
        /**
         * 项目表示
         */
        private String projectFlag;
        /**
         * 是否生成缩略图
         */
        private boolean thumb;
        /**
         * 缩略图宽度
         */
        private Integer thumbWidth = 500;
        /**
         * 缩略图高度
         */
        private Integer thumbHeight = 300;

        public String getServerUrl() {
            return serverUrl;
        }

        public void setServerUrl(String serverUrl) {
            this.serverUrl = serverUrl;
        }

        public Integer getServerConnectTimeout() {
            return serverConnectTimeout;
        }

        public void setServerConnectTimeout(Integer serverConnectTimeout) {
            this.serverConnectTimeout = serverConnectTimeout;
        }

        public Integer getServerReadTimeout() {
            return serverReadTimeout;
        }

        public void setServerReadTimeout(Integer serverReadTimeout) {
            this.serverReadTimeout = serverReadTimeout;
        }

        public List<String> getBlockSuffixList() {
            return blockSuffixList;
        }

        public void setBlockSuffixList(List<String> blockSuffixList) {
            this.blockSuffixList = blockSuffixList;
        }

        public Long getSizeLimit() {
            return sizeLimit;
        }

        public void setSizeLimit(Long sizeLimit) {
            this.sizeLimit = sizeLimit;
        }

        public boolean isThumb() {
            return thumb;
        }

        public void setThumb(boolean thumb) {
            this.thumb = thumb;
        }

        public String getProjectFlag() {
            return projectFlag;
        }

        public void setProjectFlag(String projectFlag) {
            this.projectFlag = projectFlag;
        }

        public Integer getThumbWidth() {
            return thumbWidth;
        }

        public void setThumbWidth(Integer thumbWidth) {
            this.thumbWidth = thumbWidth;
        }

        public Integer getThumbHeight() {
            return thumbHeight;
        }

        public void setThumbHeight(Integer thumbHeight) {
            this.thumbHeight = thumbHeight;
        }
    }

    public static class Export {
        /**
         * 一次可导出最大数量，为空时不限制
         */
        private Integer maxRows;

        public Integer getMaxRows() {
            return maxRows;
        }

        public void setMaxRows(Integer maxRows) {
            this.maxRows = maxRows;
        }
    }
}
